package com.lib.framework.widget.banner

import android.view.View
import android.widget.ImageView
import com.bigkoo.convenientbanner.holder.CBViewHolderCreator
import com.bigkoo.convenientbanner.holder.Holder
import com.lib.framework.R

/**
 * Copyright (C), 2020-2020, 享物说
 * FileName: SimpleImageViewHolderCreator
 * Author: keanbin
 * Date: 2020-02-09 10:13
 * Description: 简单图片banner的 CBViewHolderCreator
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
abstract class SimpleImageViewHolderCreator<T>: CBViewHolderCreator {

    override fun createHolder(itemView: View?): Holder<T> {
        return object : Holder<T>(itemView) {

            var mImageView: ImageView? = null

            override fun updateUI(data: T) {
                updateUI(data, mImageView)
            }

            override fun initView(itemView: View?) {
                if (itemView == null) return

                mImageView = itemView.findViewById(R.id.iv_image)
            }
        }
    }

    override fun getLayoutId() = R.layout.widget_banner_item_image

    abstract fun updateUI(data: T, imageView: ImageView?)
}

